package com.css.openapi.controller;


import com.css.common.core.constant.ApiAccess;
import com.css.common.core.constant.Result;
import com.css.openapi.BO.zrrdk.*;
import com.css.openapi.service.ZrrdkService;
import io.swagger.annotations.Api;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.validation.Valid;
import java.util.List;

@Api(tags = "自然人代开服务Api")
@RestController
@RequestMapping("/zrrdk")
public class ZrrdkController {

    @Resource
    private ZrrdkService zrrdkService;

    /**
     * 获取登录二维码
     *
     * @param loginEwmReq
     * @return {@link Result }<{@link LoginEwmBO }>
     */
    @PostMapping("getLoginEwm")
    @ApiAccess
    public Result<LoginEwmBO> getLoginEwm(@Validated @RequestBody LoginEwmReq loginEwmReq) {
        return zrrdkService.getLoginEwm(loginEwmReq);
    }

    /**
     * 获取二维码结果
     *
     * @param ewmResultReq
     * @return {@link Result }<{@link LoginEwmBO }>
     */
    @PostMapping("getEwmResult")
    @ApiAccess
    public Result<EwmResultBO> getEwmResult(@Validated @RequestBody EwmResultReq ewmResultReq) {
        return zrrdkService.getEwmResult(ewmResultReq);
    }

    /**
     * 提交代开申请
     *
     * @param submitDKReq
     * @return {@link Result }<{@link SubmitDKBO }>
     */
    @PostMapping("submitDK")
    @ApiAccess
    public Result<SubmitDKBO> submitDK(@Validated @RequestBody SubmitDKReq submitDKReq) {
        return zrrdkService.submitDK(submitDKReq);
    }


    /**
     * 再次提交开票
     *
     * @param submitAgainReq
     * @return {@link Result }<{@link SubmitAgainBO }>
     */
    @PostMapping("submitAgain")
    @ApiAccess
    public Result<SubmitAgainBO> submitAgain(@Validated @RequestBody SubmitAgainReq submitAgainReq) {
        return zrrdkService.submitAgain(submitAgainReq);
    }

    /**
     * 查询开票情况
     *
     * @param queryInvoiceReq
     * @return {@link Result }<{@link QueryInvoiceBO }>
     */
    @PostMapping("queryInvoice")
    @ApiAccess
    public Result<QueryInvoiceBO> queryInvoice(@Validated @RequestBody QueryInvoiceReq queryInvoiceReq) {
        return zrrdkService.queryInvoice(queryInvoiceReq);
    }

    /**
     * 查询缴税二维码
     */
    @PostMapping("/queryQrCode")
    @ApiAccess
    public Result<QrCodeRepsonse> queryQrCode(@Valid @RequestBody QrCodeReq req) {
        return Result.ok(zrrdkService.queryQrCode(req));
    }

    /**
     * 上传附件
     */
    @PostMapping("/uploadFlzl")
    @ApiAccess
    public Result uploadFlzl(@Valid @RequestBody FlzlReq req) {
        zrrdkService.uploadFlzl(req);
        return Result.ok();
    }

    /**
     * 查询可开具完税证明
     */
    @PostMapping("/queryWspzList")
    @ApiAccess
    public Result<List<WszmVO>> queryWspzList(@Valid @RequestBody WszmReq req) {
        return Result.ok(zrrdkService.queryWspzList(req));
    }

    /**
     * 下载完税证明
     */
    @PostMapping("/downloadWspz")
    @ApiAccess
    public Result<String> downloadWspz(@Valid @RequestBody DownloadWszmReq req) {
        return Result.ok(zrrdkService.downloadWspz(req));
    }
}
